import { ProTableProps, TableDropdown } from '@ant-design/pro-components';
import { UserType } from '@/types/user';

export const userTableConfig: ProTableProps<UserType, any> = {
  rowKey: 'id',
  // headerTitle='高级表格'
  search: {
    labelWidth: 'auto',
  },
  scroll: { x: 2100 },
  options: {
    setting: {
      listsHeight: 400,
    },
    fullScreen: true,
  },
  columnsState: {
    // 持久化储存
    persistenceKey: 'userManager',
    persistenceType: 'localStorage',
  },
  cardBordered: true,
  dateFormatter: 'string',
  pagination: {
    defaultPageSize: 10,
    showSizeChanger: true,
  },
  columns: [
    {
      title: '编号',
      dataIndex: 'index',
      valueType: 'indexBorder',
      width: 48,
      fixed: 'left',
    },
    {
      title: '账号',
      dataIndex: 'userName',
      copyable: true,
      ellipsis: true,
      tip: '登录账号',
      editable: false,
      filters: true,
      disable: true,
      fixed: 'left',
      formItemProps: {
        rules: [
          {
            required: false,
            message: '此项为必填项',
          },
        ],
      },
    },
    {
      disable: true,
      title: '头像',
      dataIndex: 'avatar',
      filters: false,
      search: false,
      valueType: 'avatar',
      align: 'center',
    },
    {
      disable: true,
      title: '用户昵称',
      dataIndex: 'name',
      filters: true,
      align: 'center',
    },
    {
      disable: true,
      title: '年龄',
      dataIndex: 'age',
      align: 'center',
      search: false,
    },
    {
      disable: true,
      title: '手机号',
      dataIndex: 'phone',
      search: false,
      align: 'center',
    },
    {
      disable: true,
      title: '邮箱',
      dataIndex: 'email',
      search: false,
      align: 'center',
    },
    {
      title: '备注',
      dataIndex: 'memo',
      search: false,
      ellipsis: true,
      align: 'center',
    },
    {
      title: '状态',
      dataIndex: 'online',
      onFilter: true,
      ellipsis: true,
      search: false,
      valueType: 'select',
      align: 'center',
      valueEnum: {
        open: {
          text: '未在线',
          status: 'Error',
        },
        closed: {
          text: '在线',
          status: 'Success',
        },
      },
    },
    {
      title: '创建时间',
      dataIndex: 'createTime',
      valueType: 'dateTime',
      editable: false,
      search: false,
      align: 'center',
    },
    {
      title: '修改时间',
      dataIndex: 'updatedTime',
      valueType: 'dateTime',
      editable: false,
      search: false,
      align: 'center',
    },
    {
      title: '操作',
      valueType: 'option',
      key: 'option',
      disable: true,
      fixed: 'right',
      width: 210,
    },
  ],
};
